package com.syys.privacy.service.impl;

import java.util.List;

import com.syys.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.syys.privacy.mapper.QaAnswerMapper;
import com.syys.privacy.domain.QaAnswer;
import com.syys.privacy.service.IQaAnswerService;
import com.syys.common.core.text.Convert;

/**
 * 问题答案Service业务层处理
 *
 * @author ys
 * @date 2021-07-15
 */
@Service
public class QaAnswerServiceImpl implements IQaAnswerService {
    @Autowired
    private QaAnswerMapper qaAnswerMapper;

    /**
     * 查询问题答案
     *
     * @param answerId 问题答案ID
     * @return 问题答案
     */
    @Override
    public QaAnswer selectQaAnswerById(Long answerId) {
        return qaAnswerMapper.selectQaAnswerById(answerId);
    }

    /**
     * 查询问题答案列表
     *
     * @param qaAnswer 问题答案
     * @return 问题答案
     */
    @Override
    public List<QaAnswer> selectQaAnswerList(QaAnswer qaAnswer) {
        return qaAnswerMapper.selectQaAnswerList(qaAnswer);
    }

    /**
     * 新增问题答案
     *
     * @param qaAnswer 问题答案
     * @return 结果
     */
    @Override
    public int insertQaAnswer(QaAnswer qaAnswer) {
        qaAnswer.setCreateTime(DateUtils.getNowDate());
        return qaAnswerMapper.insertQaAnswer(qaAnswer);
    }

    /**
     * 修改问题答案
     *
     * @param qaAnswer 问题答案
     * @return 结果
     */
    @Override
    public int updateQaAnswer(QaAnswer qaAnswer) {
        qaAnswer.setUpdateTime(DateUtils.getNowDate());
        return qaAnswerMapper.updateQaAnswer(qaAnswer);
    }

    /**
     * 删除问题答案对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteQaAnswerByIds(String ids) {
        return qaAnswerMapper.deleteQaAnswerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除问题答案信息
     *
     * @param answerId 问题答案ID
     * @return 结果
     */
    @Override
    public int deleteQaAnswerById(Long answerId) {
        return qaAnswerMapper.deleteQaAnswerById(answerId);
    }

    @Override
    public List<QaAnswer> selectByCode(List<String> codeList, String field) {
        return qaAnswerMapper.selectByCode(codeList, field);
    }
}
